package com.krt.webapp.activity;

import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;

import com.krt.webapp.R;
import com.krt.webapp.until.AppInfo;
import com.krt.webapp.until.MyApplication;
import com.viewpagerindicator.GFConstant;
import com.viewpagerindicator.GuideFragment;

public class YDActivity extends FragmentActivity implements GuideFragment.guidePageListener {

    private GuideFragment gf;
    private AppInfo appInfo = null;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_yd);

        appInfo = (new MyApplication(getApplication())).getAppInfo();
        //添加引导页图片列表
        int[] pics = new int[3];
        pics[0] = R.mipmap.bg1;
        pics[1] = R.mipmap.bg2;
        pics[2] = R.mipmap.bg3;

        GFConstant.PIC_LIST = pics;
        //设置圆点（默认白色）
        GFConstant.F_COLOR = R.color.indicator_blue;//圆点填充色
        GFConstant.S_COLOR = R.color.indicator_blue;//圆点边框色
        GFConstant.BT_PIC = R.mipmap.btn2;//最后一页启动按钮图标

        FragmentManager fm = getSupportFragmentManager();

        if (savedInstanceState == null) {
            gf = new GuideFragment();
            fm.beginTransaction().add(R.id.frame, gf, "gf").commit();
        } else {
            gf = (GuideFragment) fm.findFragmentByTag("gf");
        }
        gf.setListener(this);
    }

    @Override
    public void btClick() {
        //点击启动按钮
        SharedPreferences sPreferences = getSharedPreferences(appInfo.getSp_name(), 0);
        sPreferences.edit().putInt("ifopen", 1).commit();
        Intent i = new Intent();
//        i.setClass(this, WebActivity.class);
//        startActivity(i);
        overridePendingTransition(R.anim.in, R.anim.out);
    }
}
